<!DOCTYPE html>
<html>
  



<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  <!-- Global site tag (gtag.js) - Google Analytics -->


  <title>spring cloud 云服务分布式架构 | Harbour学习笔记</title>
  
    
<link rel="stylesheet" href="/blog/js/aos/aos.css">

  
  <link rel="icon" type="image/x-icon, image/vnd.microsoft.icon" href="/blog/favicon.ico">
  <link rel="stylesheet" href="https://at.alicdn.com/t/font_1911880_c1nvbyezg17.css">
  <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
  
    <script src="https://cdn.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/autoload.js"></script>
  
  
<link rel="stylesheet" href="/blog/css/animate.min.css">

  
<link rel="stylesheet" href="/blog/css/style.css">

  
  
    
<link rel="stylesheet" href="/blog/js/fancybox/jquery.fancybox.min.css">

  
  
    
<link rel="stylesheet" href="/blog/js/shareJs/share.min.css">

  
  <style>
        @media (max-width: 992px) {
            #waifu {
                display: none;
            }
        }
    </style>
<meta name="generator" content="Hexo 5.2.0"><link rel="stylesheet" href="/blog/css/prism-tomorrow.css" type="text/css"></head>

  
<script src="/blog/js/jquery3.5.1.js"></script>

  
<script src="/blog/js/vue2.6.11.js"></script>

  <body>
    <header class="header bg-color" 
  style="position: fixed; 
  left: 0; top: 0; z-index: 10;width: 100%;"
>
  <div class="header-content">
    <div class="bars">
      <div id="appDrawer" class="sidebar-image">
  <i class="fa fa-bars" aria-hidden="true" @click="showDialogDrawer"></i>
  <div class="drawer-box_mask" v-cloak style="display: none;" v-show="visible" @click.self="cancelDialogDrawer">
  </div>
  <div class="drawer-box" :class="{'active': visible}">
    <div class="drawer-box-head bg-color">
      <img class="drawer-box-head_logo" src="/medias/logo.png" alt="logo">
      <h3 class="drawer-box-head_title">Harbour学习笔记</h3>
      <h5 class="drawer-box-head_desc">大数据程序员一枚</h5>
    </div>
    <div class="drawer-box-content">
      <ul class="drawer-box-content_menu">
        
          <li class="drawer-box-content_item">
            <a href="/blog/" class="menu-item-link">
              
                <i class="fa fa-home" aria-hidden="true"></i>
              
              <span>首页</span>
            </a>
          </li>
        
          <li class="drawer-box-content_item">
            <a href="/blog/archives" class="menu-item-link">
              
                <i class="fa fa-home" aria-hidden="true"></i>
              
              <span>归档</span>
            </a>
          </li>
        
          <li class="drawer-box-content_item">
            <a href="/blog/tags" class="menu-item-link">
              
                <i class="fa fa-tags" aria-hidden="true"></i>
              
              <span>标签</span>
            </a>
          </li>
        
          <li class="drawer-box-content_item">
            <a href="/blog/categories" class="menu-item-link">
              
                <i class="fa fa-bookmark" aria-hidden="true"></i>
              
              <span>分类</span>
            </a>
          </li>
        
          <li class="drawer-box-content_item">
            <a href="/blog/about" class="menu-item-link">
              
                <i class="fa fa-user" aria-hidden="true"></i>
              
              <span>关于</span>
            </a>
          </li>
        
          <li class="drawer-box-content_item">
            <a href="/blog/friends" class="menu-item-link">
              
                <i class="fa fa-link" aria-hidden="true"></i>
              
              <span>友情链接</span>
            </a>
          </li>
        
        <li class="drawer-box-content_item">
          <a href="">
            <i class="fa fa-github" aria-hidden="true"></i>
            <span>Github</span>
          </a>
        </li>
      </ul>
    </div>
  </div>
</div>

<script>
  var body = document.body || document.documentElement || window;
  var vm = new Vue({
    el: '#appDrawer',
    data: {
      visible: false,
      top: 0,
    },
    computed: {
    },
    mounted() {
    },
    methods: {
      showDialogDrawer() {
        this.visible = true;
        // 防止页面滚动，只能让弹框滚动
        this.top = $(document).scrollTop()
        body.style.cssText = 'width: 100%; height: 100%; position: fixed; top: -' + this.top  + 'px; left: 0; overflow: hidden;';
      },
      cancelDialogDrawer() {
        this.visible = false;
        body.removeAttribute('style');
        $(document).scrollTop(this.top)
      }
    },
    created() {}
  })
</script>
    </div>
    <div class="blog-title" id="author-avatar">
      <div class="avatar">
        <img src="/medias/logo.png" alt="logo">
      </div>
      <a href="/blog/" class="logo">Harbour学习笔记</a>
    </div>
    <nav class="navbar">
      <ul class="menu">
        
          <li class="menu-item">
            <a href="/blog/" class="menu-item-link">
              
                <i class="fa fa-home" aria-hidden="true"></i>
              
              <span>首页</span>
            </a>
          </li>
        
          <li class="menu-item">
            <a href="/blog/archives" class="menu-item-link">
              
                <i class="fa fa-archive" aria-hidden="true"></i>
              
              <span>归档</span>
            </a>
          </li>
        
          <li class="menu-item">
            <a href="/blog/tags" class="menu-item-link">
              
                <i class="fa fa-tags" aria-hidden="true"></i>
              
              <span>标签</span>
            </a>
          </li>
        
          <li class="menu-item">
            <a href="/blog/categories" class="menu-item-link">
              
                <i class="fa fa-bookmark" aria-hidden="true"></i>
              
              <span>分类</span>
            </a>
          </li>
        
          <li class="menu-item">
            <a href="/blog/about" class="menu-item-link">
              
                <i class="fa fa-user" aria-hidden="true"></i>
              
              <span>关于</span>
            </a>
          </li>
        
          <li class="menu-item">
            <a href="/blog/friends" class="menu-item-link">
              
                <i class="fa fa-link" aria-hidden="true"></i>
              
              <span>友情链接</span>
            </a>
          </li>
        
      </ul>
      
        <div id="appSearch">
  <div class="search"  @click="showDialog()"><i class="fa fa-search" aria-hidden="true"></i></div>
  <div class="message-box_wrapper" style="display: none;" v-cloak v-show="dialogVisible" @click.self="cancelDialogVisible()">
    <div class="message-box">
      <h2>
        <i class="fa fa-search" aria-hidden="true"></i>
        <span class="title">搜索</span>
      </h2>
      <form class="site-search-form">
        <input type="text"
          placeholder="请输入关键字"
          id="local-search-input" 
          @click="getSearchFile()"
          class="st-search-input"
          v-model="searchInput"
        />
      </form>
      <div class="result-wrapper">
        <div id="local-search-result" class="local-search-result-cls"></div>
      </div>
    </div>
  </div>
</div>

<script src="/blog/js/local_search.js"></script>

<script>
  var body = document.body || document.documentElement || window;
  var vm = new Vue({
    el: '#appSearch',
    data: {
      dialogVisible: false,
      searchInput: '',
      top: 0,
    },
    computed: {
    },
    mounted() {
    },
    methods: {
      showDialog() {
        this.dialogVisible = true;
        // 防止页面滚动，只能让弹框滚动
        this.top = $(document).scrollTop()
        body.style.cssText = 'width: 100%; height: 100%; position: fixed; top: -' + this.top  + 'px; left: 0; overflow: hidden;';
      },
      getSearchFile() {
        if (!this.searchInput) {
          getSearchFile();
        }
      },
      cancelDialogVisible() {
        this.dialogVisible = false;
        body.removeAttribute('style');
        $(document).scrollTop(this.top)
      },
    },
    created() {}
  })
</script>
<!-- 解决刷新页面闪烁问题，可以在元素上添加display: none, 或者用vue.extend方法，详情：https://blog.csdn.net/qq_31393401/article/details/81017912 -->
<!-- 下面是搜索基本写法 -->
<!-- <script type="text/javascript" id="local.search.active">
  var inputArea = document.querySelector("#local-search-input");
  inputArea.onclick   = function(){ getSearchFile(); this.onclick = null }
  inputArea.onkeydown = function(){ if(event.keyCode == 13) return false }
</script> -->

      
    </nav>
  </div>
  
  <a target="_blank" rel="noopener" href="https://harbourzhang99.github.io" class="github-corner color-primary" aria-label="View source on GitHub"><svg width="60" height="60" viewBox="0 0 250 250" style="fill:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
</header>
    <main class="main" style="margin-top: 60px;">
      


<div class="post-detail-header" style="background: url(/medias/10.jpg) no-repeat; background-size: cover; 
  background-position: center center;">
  
    <span class="title">spring cloud 云服务分布式架构</span>
  
</div>
<div class="row justify-center">
  <div class="main-content">
    <article class="post post-detail">
      
      
      <div class="post-meta">
        <i class="fa fa-clock-o" aria-hidden="true"></i>
        <span class="post-time">2020-11-07</span>
      </div>
      
      <div class="post-tags-categories">
        
        <div class="tags">
          <i class="iconfont icontag"></i>
          
            <a href="/blog/tags/java/" class="">
              java
            </a>
          
            <a href="/blog/tags/spring-cloud/" class="">
              spring cloud
            </a>
          
        </div>
        
        
      </div>
      <div class="post-content">
        <p>一些关于微服务，分布式架构的学习笔记</p>
<a id="more"></a>

<h1 id="一、Spring-Could-Nacos-【注册中心】"><a href="#一、Spring-Could-Nacos-【注册中心】" class="headerlink" title="一、Spring Could Nacos 【注册中心】"></a>一、Spring Could Nacos 【注册中心】</h1><h2 id="1-下载地址："><a href="#1-下载地址：" class="headerlink" title="1. 下载地址："></a>1. 下载地址：</h2><p><a target="_blank" rel="noopener" href="https://github.com/alibaba/nacos/releases">https://github.com/alibaba/nacos/releases</a></p>
<h2 id="2-启动"><a href="#2-启动" class="headerlink" title="2. 启动"></a>2. 启动</h2><h3 id="（1）-bin目录下-点击startup-cmd"><a href="#（1）-bin目录下-点击startup-cmd" class="headerlink" title="（1） bin目录下  点击startup.cmd"></a>（1） bin目录下  点击startup.cmd</h3><h3 id="（2）配置依赖"><a href="#（2）配置依赖" class="headerlink" title="（2）配置依赖"></a>（2）配置依赖</h3><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span>      			    	</span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>com.alibaba.cloud<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-cloud-starter-alibaba-nacos-discovery<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">version</span>&gt;</span>2.2.1.RELEASE<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h3 id="（3）配置application-yml文件"><a href="#（3）配置application-yml文件" class="headerlink" title="（3）配置application.yml文件"></a>（3）配置application.yml文件</h3><figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">spring:</span></span><br><span class="line">  <span class="attr">application:</span></span><br><span class="line">    <span class="attr">name:</span> <span class="string">gulimall-member</span></span><br><span class="line">  <span class="attr">cloud:</span></span><br><span class="line">    <span class="attr">nacos:</span></span><br><span class="line">      <span class="attr">discovery:</span></span><br><span class="line">        <span class="attr">server-addr:</span> <span class="number">127.0</span><span class="number">.0</span><span class="number">.1</span><span class="string">:8848</span></span><br></pre></td></tr></table></figure>

<h3 id="（4）在主启动类上添加-EnableDiscoveryClient-注解"><a href="#（4）在主启动类上添加-EnableDiscoveryClient-注解" class="headerlink" title="（4）在主启动类上添加 @EnableDiscoveryClient 注解"></a>（4）在主启动类上添加 @EnableDiscoveryClient 注解</h3><h3 id="（5）启动主启动类。"><a href="#（5）启动主启动类。" class="headerlink" title="（5）启动主启动类。"></a>（5）启动主启动类。</h3><h1 id="二、SpringCloud-Feign"><a href="#二、SpringCloud-Feign" class="headerlink" title="二、SpringCloud Feign"></a>二、SpringCloud Feign</h1><p>微服务之间互相调用的一个声明式的Web Service客户端。当本服务想要调用外部服务时，使用feign来建立一个接口，本服务调用此接口，此接口再调用外部服务返回信息。</p>
<h2 id="1-使用步骤："><a href="#1-使用步骤：" class="headerlink" title="1. 使用步骤："></a>1. 使用步骤：</h2><h3 id="（1）配置依赖"><a href="#（1）配置依赖" class="headerlink" title="（1）配置依赖"></a>（1）配置依赖</h3><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.cloud<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-cloud-starter-openfeign<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h3 id="（2）告诉springcloud-使用Feign进行微服务之间的调用"><a href="#（2）告诉springcloud-使用Feign进行微服务之间的调用" class="headerlink" title="（2）告诉springcloud 使用Feign进行微服务之间的调用"></a>（2）告诉springcloud 使用Feign进行微服务之间的调用</h3><p>​        创建 Feign 包，对应的微服务Service接口， 并添加@ FeignClient注解。 注意方法名最好一致</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//  待调用服务的Controller </span></span><br><span class="line"><span class="meta">@RequestMapping(&quot;coupon/coupon&quot;)</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">CouponController</span> </span>&#123;</span><br><span class="line">    <span class="meta">@Autowired</span></span><br><span class="line">    <span class="keyword">private</span> CouponService couponService;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@RequestMapping(&quot;/test&quot;)</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> R <span class="title">couponToMember</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        CouponEntity entity = <span class="keyword">new</span> CouponEntity();</span><br><span class="line">        entity.setCouponName(<span class="string">&quot;测试使用-满100减50&quot;</span>);</span><br><span class="line">        <span class="keyword">return</span> R.ok().put(<span class="string">&quot;coupon&quot;</span>,entity);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// Feign接口 </span></span><br><span class="line"><span class="meta">@FeignClient(&quot;gulimall-coupon&quot;)</span>  <span class="comment">// 如果要调用接口的这个方法，先从注册中心的这个微服务开始寻找</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">interface</span> <span class="title">CouponFeignService</span> </span>&#123;</span><br><span class="line">    <span class="meta">@RequestMapping(&quot;/coupon/coupon/test&quot;)</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> R <span class="title">couponToMember</span><span class="params">()</span></span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 本服务的Controller  </span></span><br><span class="line"></span><br><span class="line"><span class="meta">@Resource</span></span><br><span class="line"><span class="keyword">private</span> CouponFeignService service;</span><br><span class="line"></span><br><span class="line"><span class="meta">@RequestMapping(&quot;/test&quot;)</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> R <span class="title">couponToMember</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    R r = service.couponToMember();</span><br><span class="line">    <span class="keyword">return</span> r;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="（3）在主启动类上添加-EnableFeignClient-注解"><a href="#（3）在主启动类上添加-EnableFeignClient-注解" class="headerlink" title="（3）在主启动类上添加 @EnableFeignClient 注解"></a>（3）在主启动类上添加 @EnableFeignClient 注解</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@EnableFeignClients(basePackages = &quot;com.atguigu.gulimall.member.feign&quot;)</span></span><br></pre></td></tr></table></figure>

<h1 id="三、Nacos-作为配置中心"><a href="#三、Nacos-作为配置中心" class="headerlink" title="三、Nacos 作为配置中心"></a>三、Nacos 作为配置中心</h1><h2 id="1-使用步骤：-1"><a href="#1-使用步骤：-1" class="headerlink" title="1. 使用步骤："></a>1. 使用步骤：</h2><h3 id="（1）-配置依赖："><a href="#（1）-配置依赖：" class="headerlink" title="（1） 配置依赖："></a>（1） 配置依赖：</h3><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>com.alibaba.cloud<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-cloud-starter-alibaba-nacos-config<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h3 id="（2）-创建配置文件-bootstrap-properties-并添加以下配置"><a href="#（2）-创建配置文件-bootstrap-properties-并添加以下配置" class="headerlink" title="（2） 创建配置文件 bootstrap.properties, 并添加以下配置"></a>（2） 创建配置文件 bootstrap.properties, 并添加以下配置</h3><figure class="highlight properties"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">spring.cloud.nacos.config.server-addr</span>=<span class="string">127.0.0.1:8848</span></span><br><span class="line"><span class="meta">spring.application.name</span>=<span class="string">gulimall-member</span></span><br></pre></td></tr></table></figure>

<h3 id="（3）-在Nacos服务中心创建【服务名-properties】配置文件"><a href="#（3）-在Nacos服务中心创建【服务名-properties】配置文件" class="headerlink" title="（3） 在Nacos服务中心创建【服务名.properties】配置文件"></a>（3） 在Nacos服务中心创建【服务名.properties】配置文件</h3><figure class="highlight properties"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">member.username</span>=<span class="string">harbour</span></span><br><span class="line"><span class="meta">member.info</span>=<span class="string">测试文件</span></span><br></pre></td></tr></table></figure>

<h3 id="（4）编写相关业务逻辑"><a href="#（4）编写相关业务逻辑" class="headerlink" title="（4）编写相关业务逻辑"></a>（4）编写相关业务逻辑</h3><h3 id="（5）在对应的Controller上添加-RefreshScope的注解"><a href="#（5）在对应的Controller上添加-RefreshScope的注解" class="headerlink" title="（5）在对应的Controller上添加@RefreshScope的注解"></a>（5）在对应的Controller上添加@RefreshScope的注解</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@RefreshScope</span></span><br></pre></td></tr></table></figure>

<h2 id="2-环境隔离"><a href="#2-环境隔离" class="headerlink" title="2. 环境隔离"></a>2. 环境隔离</h2><p>每个微服务创建自己的命名空间，使用配置分组区分环境，如dev，test，prod等</p>
<h3 id="（1）-命名空间："><a href="#（1）-命名空间：" class="headerlink" title="（1） 命名空间："></a>（1） 命名空间：</h3><p>默认public，用于在微服务之间进行配置隔离，每个微服务创建自己的命名空间，需要在bootstrap.properties加入以下配置：</p>
<figure class="highlight properties"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">spring.cloud.nacos.config.namespace</span>= <span class="string">【Nacos中的命名空间ID】</span></span><br></pre></td></tr></table></figure>

<h3 id="（2）-配置集："><a href="#（2）-配置集：" class="headerlink" title="（2） 配置集："></a>（2） 配置集：</h3><p>所有配置的集合</p>
<h3 id="（3）-配置集ID"><a href="#（3）-配置集ID" class="headerlink" title="（3） 配置集ID:"></a>（3） 配置集ID:</h3><p>Data-ID : 类似于配置文件名</p>
<h3 id="（4）配置分组："><a href="#（4）配置分组：" class="headerlink" title="（4）配置分组："></a>（4）配置分组：</h3><p>需要在bootstrap.properties加入以下配置：</p>
<figure class="highlight properties"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">spring.cloud.nacos.config.group</span>= <span class="string">【Nacos中的分组名】</span></span><br></pre></td></tr></table></figure>

<h2 id="3-加载多配置文件"><a href="#3-加载多配置文件" class="headerlink" title="3. 加载多配置文件"></a>3. 加载多配置文件</h2><p>在bootstrap.properties中，使用spring.cloud.nacos.config.ext-config配置配置文件。默认加载【文件名-properties】配置文件。   </p>
<figure class="highlight properties"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">spring.cloud.nacos.config.ext-config[0].data-id</span>=<span class="string">mybatis.yaml</span></span><br><span class="line"><span class="meta">spring.cloud.nacos.config.ext-config[0].group</span>=<span class="string">dev</span></span><br><span class="line"><span class="meta">spring.cloud.nacos.config.ext-config[0].refresh</span>=<span class="string">true</span></span><br><span class="line"></span><br><span class="line"><span class="meta">spring.cloud.nacos.config.ext-config[1].data-id</span>=<span class="string">datasource.yaml</span></span><br><span class="line"><span class="meta">spring.cloud.nacos.config.ext-config[1].group</span>=<span class="string">dev</span></span><br><span class="line"><span class="meta">spring.cloud.nacos.config.ext-config[1].refresh</span>=<span class="string">true</span></span><br><span class="line"></span><br><span class="line"><span class="meta">spring.cloud.nacos.config.ext-config[2].data-id</span>=<span class="string">cloud.yaml</span></span><br><span class="line"><span class="meta">spring.cloud.nacos.config.ext-config[2].group</span>=<span class="string">dev</span></span><br><span class="line"><span class="meta">spring.cloud.nacos.config.ext-config[2].refresh</span>=<span class="string">true</span></span><br></pre></td></tr></table></figure>

<h1 id="四、Spring-Cloud-Gateway"><a href="#四、Spring-Cloud-Gateway" class="headerlink" title="四、Spring Cloud Gateway"></a>四、Spring Cloud Gateway</h1><h2 id="1-使用步骤"><a href="#1-使用步骤" class="headerlink" title="1.使用步骤"></a>1.使用步骤</h2><h3 id="（1）导入依赖："><a href="#（1）导入依赖：" class="headerlink" title="（1）导入依赖："></a>（1）导入依赖：</h3><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.cloud<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-cloud-starter-gateway<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h3 id="（2）根据不同的需求，配置yaml"><a href="#（2）根据不同的需求，配置yaml" class="headerlink" title="（2）根据不同的需求，配置yaml"></a>（2）根据不同的需求，配置yaml</h3><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">spring:</span></span><br><span class="line">  <span class="attr">cloud:</span></span><br><span class="line">    <span class="attr">gateway:</span></span><br><span class="line">      <span class="attr">routes:</span></span><br><span class="line">        <span class="bullet">-</span> <span class="attr">id:</span> <span class="string">admin_route</span></span><br><span class="line">          <span class="attr">uri:</span> <span class="string">lb://renren-fast</span></span><br><span class="line">          <span class="attr">predicates:</span></span><br><span class="line">            <span class="bullet">-</span> <span class="string">Path=/api/**</span></span><br><span class="line">          <span class="attr">filters:</span></span><br><span class="line">            <span class="bullet">-</span> <span class="string">RewritePath=/api/(?&lt;segment&gt;.*),/renren-fast/$\&#123;segment&#125;</span></span><br><span class="line">    <span class="attr">nacos:</span></span><br><span class="line">      <span class="attr">discovery:</span></span><br><span class="line">        <span class="attr">server-addr:</span> <span class="number">127.0</span><span class="number">.0</span><span class="number">.1</span><span class="string">:8848</span></span><br><span class="line">  <span class="attr">application:</span></span><br><span class="line">    <span class="attr">name:</span> <span class="string">gulimall-gateway</span></span><br><span class="line"></span><br><span class="line"><span class="attr">server:</span></span><br><span class="line">  <span class="attr">port:</span> <span class="number">88</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="3-修改主启动类"><a href="#3-修改主启动类" class="headerlink" title="(3) 修改主启动类"></a>(3) 修改主启动类</h3><p>在主启动类上增加@EnableDiscoveyClient 注解</p>
<h1 id="五、解决浏览器跨域"><a href="#五、解决浏览器跨域" class="headerlink" title="五、解决浏览器跨域"></a>五、解决浏览器跨域</h1><h2 id="解决方案："><a href="#解决方案：" class="headerlink" title="解决方案："></a>解决方案：</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Configuration</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">MyCorsConfiguration</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> CorsWebFilter <span class="title">getCorsWebFilter</span> <span class="params">()</span> </span>&#123;</span><br><span class="line">        UrlBasedCorsConfigurationSource source = <span class="keyword">new</span> UrlBasedCorsConfigurationSource();</span><br><span class="line">        </span><br><span class="line">        CorsConfiguration configuration = <span class="keyword">new</span> CorsConfiguration();</span><br><span class="line">        configuration.addAllowedHeader(<span class="string">&quot;*&quot;</span>);</span><br><span class="line">        configuration.addAllowedMethod(<span class="string">&quot;*&quot;</span>);</span><br><span class="line">        configuration.addAllowedOrigin(<span class="string">&quot;*&quot;</span>);</span><br><span class="line">        configuration.setAllowCredentials(<span class="keyword">true</span>);</span><br><span class="line">        </span><br><span class="line">        source.registerCorsConfiguration(<span class="string">&quot;/**&quot;</span>,configuration);</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> CorsWebFilter(source);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h1 id="六、整合MybatisPlus"><a href="#六、整合MybatisPlus" class="headerlink" title="六、整合MybatisPlus"></a>六、整合MybatisPlus</h1><h2 id="1-导入依赖"><a href="#1-导入依赖" class="headerlink" title="1.导入依赖"></a>1.导入依赖</h2><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>com.baomidou<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>mybatis-plus-boot-starter<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">version</span>&gt;</span>3.3.1<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">&lt;!-- 数据源 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>com.alibaba<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>druid<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">version</span>&gt;</span>1.1.13<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h2 id="2-配置"><a href="#2-配置" class="headerlink" title="2. 配置"></a>2. 配置</h2><h3 id="（1）配置数据源"><a href="#（1）配置数据源" class="headerlink" title="（1）配置数据源"></a>（1）配置数据源</h3><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 配置mybatisplus</span></span><br><span class="line"><span class="attr">mybatis-plus:</span></span><br><span class="line">  <span class="comment"># MyBatis Mapper 所对应的 XML 文件位置</span></span><br><span class="line">  <span class="comment"># Maven 多模块项目的扫描路径需以 classpath*: 开头 （即加载多个 jar 包下的 XML 文件）</span></span><br><span class="line">  <span class="attr">mapper-locations:</span> <span class="string">classpath*:/mapper/**/*.xml</span></span><br><span class="line"></span><br><span class="line">  <span class="comment"># 设置主键自增</span></span><br><span class="line">  <span class="attr">global-config:</span></span><br><span class="line">    <span class="attr">db-config:</span></span><br><span class="line">      <span class="attr">id-type:</span> <span class="string">auto</span></span><br></pre></td></tr></table></figure>

<h3 id="（2）使用-MapperScan注解"><a href="#（2）使用-MapperScan注解" class="headerlink" title="（2）使用@MapperScan注解"></a>（2）使用@MapperScan注解</h3><p>使用@MapperScan注解告诉MybatisPlus的sql映射位置</p>
<h2 id="3-逻辑删除"><a href="#3-逻辑删除" class="headerlink" title="3.逻辑删除"></a>3.逻辑删除</h2><h3 id="（1）配置yaml-注：since-3-3-0-配置后可以忽略不配置步骤2"><a href="#（1）配置yaml-注：since-3-3-0-配置后可以忽略不配置步骤2" class="headerlink" title="（1）配置yaml  (注：since 3.3.0,配置后可以忽略不配置步骤2)"></a>（1）配置yaml  (注：since 3.3.0,配置后可以忽略不配置步骤2)</h3><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">mybatis-plus:</span></span><br><span class="line">  <span class="attr">global-config:</span></span><br><span class="line">    <span class="attr">db-config:</span></span><br><span class="line">      <span class="attr">logic-delete-field:</span> <span class="string">flag</span>  <span class="comment"># 全局逻辑删除的实体字段名(since 3.3.0,配置后可以忽略不配置步骤2)</span></span><br><span class="line">      <span class="attr">logic-delete-value:</span> <span class="number">1</span> <span class="comment"># 逻辑已删除值(默认为 1)</span></span><br><span class="line">      <span class="attr">logic-not-delete-value:</span> <span class="number">0</span> <span class="comment"># 逻辑未删除值(默认为 0)</span></span><br></pre></td></tr></table></figure>

<h3 id="（2）实体类字段上加上-TableLogic注解"><a href="#（2）实体类字段上加上-TableLogic注解" class="headerlink" title="（2）实体类字段上加上@TableLogic注解"></a>（2）实体类字段上加上<code>@TableLogic</code>注解</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@TableLogic</span></span><br><span class="line"><span class="keyword">private</span> Integer deleted;</span><br></pre></td></tr></table></figure>


      </div>
      
        <div class="copyright">
  <ul class="post-copyright">
    <li class="post-copyright-author">
    <strong>作者:  </strong>Harbour</a>
    </li>
    <li class="post-copyright-link">
    <strong>文章链接:  </strong>
    <a href="/blog/2020/11/07/GuliMall/" target="_blank" title="spring cloud 云服务分布式架构">https://harbourzhang99.gitee.io/blog/2020/11/07/GuliMall/</a>
    </li>
    <li class="post-copyright-license">
      <strong>版权声明:   </strong>
      本网站所有文章除特别声明外,均采用 <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">CC BY-NC-ND 4.0</a>
      许可协议。转载请注明出处!
    </li>
  </ul>
<div>
      
    </article>
    <!-- 上一篇文章和下一篇文章 -->
    
      <div class="post-nav">

  <div class="post-nav-prev post-nav-item">
    <a href="/blog/2020/11/09/Leetcode0002/">
      上一篇:    Leetcode  0002
    </a>
  </div>



</div>

    
    

    <!-- 打赏 -->
    
      <div id="appDonate" class="post-donate">
  <div id="donate_board" class="donate_bar center" ref="donate">
    <a id="btn_donate" class="btn_donate" href="javascript:;" title="打赏" @click="showDialogDrawer()"></a>
  </div>
  <transition name="fade">
    <div 
      class="donate-box-mask"
      v-cloak 
      v-if="visible"
      @click="cancelDialogDrawer()"
    >
    </div>
  </transition>
  <transition name="bounce">
    <div class="donate-box" v-cloak v-if="visible">
      <div class="donate-box_close">
        <i class="fa fa-times" aria-hidden="true" @click="cancelDialogDrawer"></i>
      </div>
      <div class="donate-box_title">
        <h4>
          你的赏识是我前进的动力
        </h4>
      </div>
      <div class="donate-box_tab">
        <div class="Alipay" :class="{'active': tabActive === 'Alipay'}" @click="changeTabActive('Alipay')">
          支付宝
        </div>
        <div class="WeChatpay" :class="{'active': tabActive === 'WeChatpay'}" @click="changeTabActive('WeChatpay')">
          微信
        </div>
      </div>
      <div class="donate-box_img">
        <div class="AlipayImg" v-if="tabActive === 'Alipay'">
          <img src="/medias/zfb.jpg" alt="支付宝打赏" />
        </div> 
        <div class="WeChatpayImg" v-if="tabActive === 'WeChatpay'">
          <img src="/medias/wx.jpg" alt="微信打赏" />
        </div>
      </div>
    </div>
  </transition>
</div>

<script>
  var body = document.body || document.documentElement || window;
  var vm = new Vue({
    el: '#appDonate',
    data: {
      visible: false,
      tabActive: 'Alipay',
      top: 0,
    },
    computed: {
    },
    mounted() {
    },
    methods: {
      showDialogDrawer() {
        this.visible = true;
        // 防止页面滚动，只能让弹框滚动
        // function getScroll() {
        //   return {
        //     left: window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0,
        //     top: window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0
        //   };
        // }
        this.top = $(document).scrollTop() // or getScroll().top
        body.style.cssText = 'width: 100%; height: 100%; position: fixed; top: -' + this.top + 'px; left: 0; overflow: hidden;';
      },
      cancelDialogDrawer() {
        this.visible = false;
        body.removeAttribute('style');
        $(document).scrollTop(this.top)
      },
      changeTabActive(name) {
        this.tabActive = name;
      }
    },
    created() {}
  })
</script>
    

    <!-- 分享 -->
    
      <!-- https://github.com/overtrue/share.js -->

<div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>



<script src="/blog/js/shareJs/social-share.min.js"></script>

</script>

<style>
  .social-share {
    margin: 20px 0;
  }
</style>


    

    <!-- 评论 -->
      
        
      
  </div>

  
    <div class="toc-aside">
      <div class="toc-main">
        <div class="toc-aside-title">
          <i class="fa fa-list-ul" aria-hidden="true"></i><span>目录</span>
        </div>
        <div class="toc-content">
          <link href="/js/tocbot/tocbot.css" rel="stylesheet">
<script src="/js/tocbot/tocbot.min.js"></script>
<div class="toc"></div>

<script>
  if ($('.toc').length > 0) {
    var headerEl = 'h2, h3, h4',  //headers 
      content = '.post-detail',//文章容器
      idArr = {};  //标题数组以确定是否增加索引id
      //add #id

    $(content).children(headerEl).each(function () {
      //去除空格以及多余标点
      var headerId = $(this).text().replace(/[\s|\~|`|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\_|\+|\=|\||\|\[|\]|\{|\}|\;|\:|\"|\'|\,|\<|\.|\>|\/|\?|\：|\，|\。]/g, '');

      headerId = headerId.toLowerCase();
      if (idArr[headerId]) {
        //id已经存在
        $(this).attr('id', headerId + '-' + idArr[headerId]);
        idArr[headerId]++;
      }
      else {
        //id未存在
        idArr[headerId] = 1;
        $(this).attr('id', headerId);
      }
    });

    tocbot.init({
      // Where to render the table of contents.
      tocSelector: '.toc',
      // Where to grab the headings to build the table of contents.
      contentSelector: content,
      // Which headings to grab inside of the contentSelector element.
      headingSelector: headerEl,
      scrollSmooth: true,
      scrollSmoothOffset: -80,
      headingsOffset: 130,
      positionFixedSelector: '.toc-main',
      positionFixedClass: 'is-position-fixed',
      fixedSidebarOffset: 'auto',
    });
  }

</script>

<style>
.is-position-fixed {
  position:fixed !important;
  top: 64px;
}

</style>
        </div>
      </div>
    </div>
  
</div>

    </main>
    <div class="footer bg-color">
  <div class="footer-main">
    <div class="link">
      <a target="_blank" rel="noopener" href="https://github.com/yuang01/hexo-theme-bamboo">
        <i class="fa fa-github" aria-hidden="true"></i>
      </a>
      <a href="mailto:1730241541@qq.com">
        <i class="fa fa-envelope-o" aria-hidden="true"></i>
      </a>
      <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=1730241541">
        <i class="fa fa-qq" aria-hidden="true"></i>
      </a>
      <a href="/atom.xml" target="_blank">
        <i class="fa fa-rss" aria-hidden="true"></i>
      </a>
    </div>
    <div class="footer-copyright">
      Copyright © 2019 - 2020 <a target="_blank" rel="noopener" href="https://github.com/yuang01">yuang01</a> | Powered by <a target="_blank" rel="noopener" href="https://hexo.io/zh-cn/docs/">Hexo</a> | Theme <a target="_blank" rel="noopener" href="https://github.com/yuang01/theme">Bamboo</a> 
    </div>
    
      
  <!-- 不蒜子统计 -->
  <span id="busuanzi_container_site_pv">
        <i class="fa fa-book" aria-hidden="true"></i>本站总阅读量：<span id="busuanzi_value_page_pv"></span> 次
  </span>
  <span id="busuanzi_container_site_pv">
        <i class="fa fa-eye" aria-hidden="true"></i>本站总访问量：<span id="busuanzi_value_site_pv"></span> 次
  </span>
  <span class="post-meta-divider">|</span>
  <span id="busuanzi_container_site_uv" style='display:none'>
        <i class="fa fa-users" aria-hidden="true"></i>本站访客数：<span id="busuanzi_value_site_uv"></span> 人
  </span>
  <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

    
  </div>
</div>


    
      <div class="goTop bg-color">
  <i class="fa fa-arrow-up" aria-hidden="true"></i>
</div>

<script src="/blog/js/goTop.js"></script>

    

    
      <link href="https://cdn.bootcdn.net/ajax/libs/aplayer/1.10.1/APlayer.min.css" rel="stylesheet">
<style>
.aplayer .aplayer-lrc p {
  
  display: none;
  
  font-size: 12px;
  font-weight: 700;
  line-height: 16px !important;
}

.aplayer .aplayer-lrc p.aplayer-lrc-current {
  
  display: none;
  
  font-size: 15px;
  color: #42b983;
}


.aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
  left: -66px !important;
}

.aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
  left: 0px !important;
}


</style>
<meting-js  
  class=""
  server="netease"
  type="playlist"
  id="442274724"
  fixed='true'
  autoplay='false'
  theme='#42b983'
  loop='all'
  order='random'
  preload='auto'
  volume='0.7'
  list-folded='true'
>
</meting-js>

<!-- <style>
  #aplayer {
    position: fixed;
    left: 0;
    bottom: 300px;
  }
</style> -->
<script src="https://cdn.bootcdn.net/ajax/libs/aplayer/1.10.1/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>
    

    <!-- 图片放大 -->
    
      
<script src="/blog/js/fancybox/jquery.fancybox.min.js"></script>
<script src="/blog/js/wrapImage.js"></script>

    

    <!-- 爱心点击 -->
    
      
<script src="/blog/js/clicklove.js"></script>

    

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script type="text/javascript" size="100" alpha='0.4' zIndex="-1" src="/js/ribbon.min.js"></script>
    
      
<script src="/blog/js/aos/aos.js"></script>

      <script>
        // https://github.com/michalsnik/aos
        const themeOffset = parseInt('120') || 120;
        const themeDelay = parseInt('0')|| 0;
        const themeDuration = parseInt('400') || 400;
        const themeEasing = 'ease' || 'ease';
        const themeOnce = JSON.parse('true' || true);
        const themeMirror = JSON.parse('false' || false);
        const themeAnchorPlacement = 'top-bottom' || 'top-bottom';
        AOS.init({
          // Global settings:
          disable: false, // accepts following values: 'phone', 'tablet', 'mobile', boolean, expression or function
          startEvent: 'DOMContentLoaded', // name of the event dispatched on the document, that AOS should initialize on
          initClassName: 'aos-init', // class applied after initialization
          animatedClassName: 'aos-animate', // class applied on animation
          useClassNames: false, // if true, will add content of `data-aos` as classes on scroll
          disableMutationObserver: false, // disables automatic mutations' detections (advanced)
          debounceDelay: 50, // the delay on debounce used while resizing window (advanced)
          throttleDelay: 99, // the delay on throttle used while scrolling the page (advanced)

          // Settings that can be overridden on per-element basis, by `data-aos-*` attributes:
          offset: themeOffset, // offset (in px) from the original trigger point
          delay: themeDelay, // values from 0 to 3000, with step 50ms
          duration: themeDuration, // values from 0 to 3000, with step 50ms
          easing: themeEasing, // default easing for AOS animations
          once: themeOnce, // whether animation should happen only once - while scrolling down
          mirror: themeMirror, // whether elements should animate out while scrolling past them
          anchorPlacement: themeAnchorPlacement, // defines which position of the element regarding to window should trigger the animation

        });
      </script>
    

    
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/v-plugs-ayu/lib/ayu.css">
<script src="https://cdn.jsdelivr.net/npm/v-plugs-ayu/lib/ayu.umd.min.js"></script>
<div id="appCopy">
</div>
<script>
  var vm = new Vue({
    el: '#appCopy',
    data: {
    },
    computed: {
    },
    mounted() {
      const that = this;
      //  监听 ctrl + c事件  
      $(document).unbind('keypress').bind('keypress', function (e) {
        if (e.ctrlKey && e.keyCode == 67) {
          doSomething();
          // 返回false, 防止重复触发copy事件  
          return false;
        }
      })

      // 鼠标右键的复制事件  
      $(document).unbind('copy').bind('copy', function (e) {
        doSomething();
        // console.log('右键复制 监听成功');
      });

      function doSomething() {
        that.$notify({
          title: '成功',
          content: '复制成功了哦',
          type: 'success'
        })
        // console.log('ctrl + c 监听成功');  
      }
    },
    methods: {
    },
    created() { }
  })
</script>
    

    <!-- 输入框打字特效 -->
    
      
<script src="/blog/js/activate-power-mode.js"></script>

      <script>
          POWERMODE.colorful = true;  // 打开随机颜色特效
          POWERMODE.shake = false;    // 关闭输入框抖动
          document.body.addEventListener('input', POWERMODE);//监听打字事件
      </script>
    

    <!-- markdown代码一键复制功能 -->
    
<script src="/blog/js/clipboard/clipboard.min.js"></script>

    <script>
      !function (e, t, a) {
        var copy = '复制';
        /* code */
        var initCopyCode = function(){
          var copyHtml = '';
          copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
          copyHtml += '<i class="fa fa-globe"></i><span>' + copy + '</span>';
          copyHtml += '</button>';
          $(".post-detail pre code").before(copyHtml);
          new ClipboardJS('.btn-copy', {
              target: function(trigger) {
                  return trigger.nextElementSibling;
              }
          });
        }
        initCopyCode();
      }(window, document);
    </script>
  
  </body>
</html>